/**
 *
 */
import Util;
import GatewayClient;
import OpenApi;
import OpenApiUtil;
import EndpointUtil;

extends OpenApi;


init(config: OpenApi.Config){
  super(config);
  @productId = 'EmrStudio';
  var gatewayClient = new GatewayClient();
  @spi = gatewayClient;
  @endpointRule = '';
  
  checkConfig(config);
  @endpoint = getEndpoint('emrstudio', @regionId, @endpointRule, @network, @suffix, @endpointMap, @endpoint);
}

function getEndpoint(productId: string, regionId: string, endpointRule: string, network: string, suffix: string, endpointMap: map[string]string, endpoint: string) throws: string{
  if (!Util.empty(endpoint)) {
    return endpoint;
  }
  
  if (!Util.isUnset(endpointMap) && !Util.empty(endpointMap[regionId])) {
    return endpointMap[regionId];
  }
  return EndpointUtil.getEndpointRules(productId, regionId, endpointRule, network, suffix);
}

model CreateWorkflowRequest {
  alertGroupId?: string(name='alertGroupId', example='ag-v7n2gp3vv3j****'),
  alertStrategy?: string(name='alertStrategy', example='NONE'),
  taskDefinitionJsonValue?: string(name='taskDefinitionJsonValue'),
  taskRelationJsonValue?: string(name='taskRelationJsonValue'),
  cronExpr?: string(name='cronExpr', example='0 0 * * * ? *'),
  description?: string(name='description', example='test'),
  executionType?: string(name='executionType', example='PARALLEL'),
  failureStrategy?: string(name='failureStrategy', example='END'),
  name?: string(name='name', description='This parameter is required.', example='test'),
  parentDirectoryId?: string(name='parentDirectoryId', example='wd-v7n2gp3vv3j****'),
  resourceGroupId?: string(name='resourceGroupId', example='wg-acfmv4opbs****'),
  scheduleEndTime?: string(name='scheduleEndTime', example='2024-01-01 00:00:00'),
  scheduleStartTime?: string(name='scheduleStartTime', example='2024-01-01 00:00:00'),
  scheduleState?: string(name='scheduleState', example='OFFLINE'),
  taskDefinitionJson?: string(name='taskDefinitionJson', description='This parameter is required.', example='[{"taskId":"t1","name":"t1","taskParams":{"rawScript":"echo 1"},"taskType":"SHELL"}]'),
  taskRelationJson?: string(name='taskRelationJson', description='This parameter is required.', example='[{"preTaskId":"0", "postTaskId":"t1"}]'),
  timeZone?: string(name='timeZone', example='Asia/Shanghai'),
  timeout?: int32(name='timeout', example='10'),
  workflowInstancePriority?: string(name='workflowInstancePriority', example='MEDIUM'),
  workflowParams?: string(name='workflowParams', example='[{"prop":"key1","value":"value1"}]'),
  workspaceId?: string(name='workspaceId', description='This parameter is required.', example='12345'),
}

model CreateWorkflowResponseBody = {
  data?: {
    workflowId?: string(name='workflowId', example='w-acfmv4opbs****'),
  }(name='data'),
  requestId?: string(name='requestId', description='Id of the request', example='9E3A7161-EB7B-172B-8D18-FFB06BA38***'),
  success?: boolean(name='success', example='True'),
}

model CreateWorkflowResponse = {
  headers?: map[string]string(name='headers'),
  statusCode?: int32(name='statusCode'),
  body?: CreateWorkflowResponseBody(name='body'),
}

/**
 * @summary 创建工作流
 *
 * @param request CreateWorkflowRequest
 * @param headers map
 * @param runtime runtime options for this request RuntimeOptions
 * @return CreateWorkflowResponse
 */
async function createWorkflowWithOptions(projectId: string, request: CreateWorkflowRequest, headers: map[string]string, runtime: Util.RuntimeOptions): CreateWorkflowResponse {
  Util.validateModel(request);
  var query : map[string]any = {};
  if (!Util.isUnset(request.alertGroupId)) {
    query['alertGroupId'] = request.alertGroupId;
  }
  if (!Util.isUnset(request.alertStrategy)) {
    query['alertStrategy'] = request.alertStrategy;
  }
  if (!Util.isUnset(request.cronExpr)) {
    query['cronExpr'] = request.cronExpr;
  }
  if (!Util.isUnset(request.description)) {
    query['description'] = request.description;
  }
  if (!Util.isUnset(request.executionType)) {
    query['executionType'] = request.executionType;
  }
  if (!Util.isUnset(request.failureStrategy)) {
    query['failureStrategy'] = request.failureStrategy;
  }
  if (!Util.isUnset(request.name)) {
    query['name'] = request.name;
  }
  if (!Util.isUnset(request.parentDirectoryId)) {
    query['parentDirectoryId'] = request.parentDirectoryId;
  }
  if (!Util.isUnset(request.resourceGroupId)) {
    query['resourceGroupId'] = request.resourceGroupId;
  }
  if (!Util.isUnset(request.scheduleEndTime)) {
    query['scheduleEndTime'] = request.scheduleEndTime;
  }
  if (!Util.isUnset(request.scheduleStartTime)) {
    query['scheduleStartTime'] = request.scheduleStartTime;
  }
  if (!Util.isUnset(request.scheduleState)) {
    query['scheduleState'] = request.scheduleState;
  }
  if (!Util.isUnset(request.taskDefinitionJson)) {
    query['taskDefinitionJson'] = request.taskDefinitionJson;
  }
  if (!Util.isUnset(request.taskRelationJson)) {
    query['taskRelationJson'] = request.taskRelationJson;
  }
  if (!Util.isUnset(request.timeZone)) {
    query['timeZone'] = request.timeZone;
  }
  if (!Util.isUnset(request.timeout)) {
    query['timeout'] = request.timeout;
  }
  if (!Util.isUnset(request.workflowInstancePriority)) {
    query['workflowInstancePriority'] = request.workflowInstancePriority;
  }
  if (!Util.isUnset(request.workflowParams)) {
    query['workflowParams'] = request.workflowParams;
  }
  if (!Util.isUnset(request.workspaceId)) {
    query['workspaceId'] = request.workspaceId;
  }

  var body : map[string]any = {};
  if (!Util.isUnset(request.taskDefinitionJsonValue)) {
    body['taskDefinitionJsonValue'] = request.taskDefinitionJsonValue;
  }
  if (!Util.isUnset(request.taskRelationJsonValue)) {
    body['taskRelationJsonValue'] = request.taskRelationJsonValue;
  }

  var req = new OpenApi.OpenApiRequest{ 
    headers = headers,
    query = OpenApiUtil.query(query),
    body = OpenApiUtil.parseToMap(body),
  };
  var params = new OpenApi.Params{
    action = 'CreateWorkflow',
    version = '2024-04-30',
    protocol = 'HTTPS',
    pathname = `/dolphinscheduler/v3/projects/${OpenApiUtil.getEncodeParam(projectId)}/workflows`,
    method = 'POST',
    authType = 'AK',
    style = 'ROA',
    reqBodyType = 'json',
    bodyType = 'json',
  };
  if (Util.isUnset(@signatureVersion) || !Util.equalString(@signatureVersion, 'v4')) {
    return callApi(params, req, runtime);
  } else {
    return execute(params, req, runtime);
  }
}

/**
 * @summary 创建工作流
 *
 * @param request CreateWorkflowRequest
 * @return CreateWorkflowResponse
 */
async function createWorkflow(projectId: string, request: CreateWorkflowRequest): CreateWorkflowResponse {
  var runtime = new Util.RuntimeOptions{};
  var headers : map[string]string = {};
  return createWorkflowWithOptions(projectId, request, headers, runtime);
}

model DeleteWorkflowRequest {
  workspaceId?: string(name='workspaceId', description='This parameter is required.', example='12345'),
}

model DeleteWorkflowResponseBody = {
  requestId?: string(name='requestId', description='Id of the request', example='DD6B1B2A-5837-5237-ABE4-FF0C8944****'),
  success?: boolean(name='success', example='True'),
}

model DeleteWorkflowResponse = {
  headers?: map[string]string(name='headers'),
  statusCode?: int32(name='statusCode'),
  body?: DeleteWorkflowResponseBody(name='body'),
}

/**
 * @summary 删除工作流
 *
 * @param request DeleteWorkflowRequest
 * @param headers map
 * @param runtime runtime options for this request RuntimeOptions
 * @return DeleteWorkflowResponse
 */
async function deleteWorkflowWithOptions(projectId: string, workflowId: string, request: DeleteWorkflowRequest, headers: map[string]string, runtime: Util.RuntimeOptions): DeleteWorkflowResponse {
  Util.validateModel(request);
  var query : map[string]any = {};
  if (!Util.isUnset(request.workspaceId)) {
    query['workspaceId'] = request.workspaceId;
  }

  var req = new OpenApi.OpenApiRequest{ 
    headers = headers,
    query = OpenApiUtil.query(query),
  };
  var params = new OpenApi.Params{
    action = 'DeleteWorkflow',
    version = '2024-04-30',
    protocol = 'HTTPS',
    pathname = `/dolphinscheduler/v3/projects/${OpenApiUtil.getEncodeParam(projectId)}/workflows/${OpenApiUtil.getEncodeParam(workflowId)}`,
    method = 'DELETE',
    authType = 'AK',
    style = 'ROA',
    reqBodyType = 'json',
    bodyType = 'json',
  };
  if (Util.isUnset(@signatureVersion) || !Util.equalString(@signatureVersion, 'v4')) {
    return callApi(params, req, runtime);
  } else {
    return execute(params, req, runtime);
  }
}

/**
 * @summary 删除工作流
 *
 * @param request DeleteWorkflowRequest
 * @return DeleteWorkflowResponse
 */
async function deleteWorkflow(projectId: string, workflowId: string, request: DeleteWorkflowRequest): DeleteWorkflowResponse {
  var runtime = new Util.RuntimeOptions{};
  var headers : map[string]string = {};
  return deleteWorkflowWithOptions(projectId, workflowId, request, headers, runtime);
}

model DescribeManualTaskRequest {
  workspaceId?: string(name='workspaceId', description='This parameter is required.', example='123***'),
}

model DescribeManualTaskResponseBody = {
  createTime?: string(name='CreateTime', example='2024-03-27 00:00:00'),
  description?: string(name='Description', example='test'),
  manualTaskId?: string(name='ManualTaskId', example='mt-3q9jo749ne5****'),
  manualTaskName?: string(name='ManualTaskName', example='test'),
  parentDirectoryId?: string(name='ParentDirectoryId', example='mtd-oy98v7n43el****'),
  projectId?: string(name='ProjectId', example='p-3q9jo749ne5****'),
  resourceIds?: string(name='ResourceIds', example='r-oy98v7n43el****'),
  taskParams?: string(name='TaskParams', example='{
    "yarnUser": "",
    "conditionResult": "null",
    "rawScript": "sleep 300",
    "submitOnYarnFlag": false,
    "emrClusterId": "",
    "yarnPriority": "",
    "dependence": "null",
    "yarnMemory": "",
    "localParams": [],
    "switchResult": "null",
    "resourceList": [],
    "yarnQueue": "",
    "yarnVCores": "",
    "associateManualTaskFlag": false
}'),
  taskType?: string(name='TaskType', example='SHELL'),
  updateTime?: string(name='UpdateTime', example='2024-03-27 00:00:00'),
  requestId?: string(name='requestId', description='Id of the request', example='DD6B1B2A-5837-5237-ABE4-FF0C8944****'),
}

model DescribeManualTaskResponse = {
  headers?: map[string]string(name='headers'),
  statusCode?: int32(name='statusCode'),
  body?: DescribeManualTaskResponseBody(name='body'),
}

/**
 * @summary 获取手动任务定义
 *
 * @param request DescribeManualTaskRequest
 * @param headers map
 * @param runtime runtime options for this request RuntimeOptions
 * @return DescribeManualTaskResponse
 */
async function describeManualTaskWithOptions(projectId: string, manualTaskId: string, request: DescribeManualTaskRequest, headers: map[string]string, runtime: Util.RuntimeOptions): DescribeManualTaskResponse {
  Util.validateModel(request);
  var query : map[string]any = {};
  if (!Util.isUnset(request.workspaceId)) {
    query['workspaceId'] = request.workspaceId;
  }

  var req = new OpenApi.OpenApiRequest{ 
    headers = headers,
    query = OpenApiUtil.query(query),
  };
  var params = new OpenApi.Params{
    action = 'DescribeManualTask',
    version = '2024-04-30',
    protocol = 'HTTPS',
    pathname = `/dolphinscheduler/v3/projects/${OpenApiUtil.getEncodeParam(projectId)}/manualTasks/${OpenApiUtil.getEncodeParam(manualTaskId)}`,
    method = 'GET',
    authType = 'AK',
    style = 'ROA',
    reqBodyType = 'json',
    bodyType = 'json',
  };
  if (Util.isUnset(@signatureVersion) || !Util.equalString(@signatureVersion, 'v4')) {
    return callApi(params, req, runtime);
  } else {
    return execute(params, req, runtime);
  }
}

/**
 * @summary 获取手动任务定义
 *
 * @param request DescribeManualTaskRequest
 * @return DescribeManualTaskResponse
 */
async function describeManualTask(projectId: string, manualTaskId: string, request: DescribeManualTaskRequest): DescribeManualTaskResponse {
  var runtime = new Util.RuntimeOptions{};
  var headers : map[string]string = {};
  return describeManualTaskWithOptions(projectId, manualTaskId, request, headers, runtime);
}

model DescribeManualTaskInstanceRequest {
  workspaceId?: string(name='workspaceId', description='This parameter is required.', example='123***'),
}

model DescribeManualTaskInstanceResponseBody = {
  emrClusterId?: string(name='EmrClusterId', example='c-b933c5aac7f7***'),
  endTime?: string(name='EndTime', example='2024-03-27 00:00:00'),
  externalAppId?: string(name='ExternalAppId', example='application_123_***'),
  manualTaskInstanceId?: string(name='ManualTaskInstanceId', example='mti-0k5vype05xm****'),
  manualTaskInstanceName?: string(name='ManualTaskInstanceName', example='test'),
  resourceGroupId?: string(name='ResourceGroupId', example='wg-123abc***'),
  startTime?: string(name='StartTime', example='2024-03-27 00:00:00'),
  status?: string(name='Status', example='SUCCESS'),
  submitTime?: string(name='SubmitTime', example='2024-03-27 00:00:00'),
  taskParams?: string(name='TaskParams', example='{
    "yarnUser": "",
    "conditionResult": "null",
    "rawScript": "sleep 300",
    "submitOnYarnFlag": false,
    "emrClusterId": "",
    "yarnPriority": "",
    "dependence": "null",
    "yarnMemory": "",
    "localParams": [],
    "switchResult": "null",
    "resourceList": [],
    "yarnQueue": "",
    "yarnVCores": "",
    "associateManualTaskFlag": false
}'),
  taskType?: string(name='TaskType', example='SHELL'),
  requestId?: string(name='requestId', description='Id of the request', example='DD6B1B2A-5837-5237-ABE4-FF0C8944****'),
}

model DescribeManualTaskInstanceResponse = {
  headers?: map[string]string(name='headers'),
  statusCode?: int32(name='statusCode'),
  body?: DescribeManualTaskInstanceResponseBody(name='body'),
}

/**
 * @summary 获取手动任务实例
 *
 * @param request DescribeManualTaskInstanceRequest
 * @param headers map
 * @param runtime runtime options for this request RuntimeOptions
 * @return DescribeManualTaskInstanceResponse
 */
async function describeManualTaskInstanceWithOptions(manualTaskInstanceId: string, projectId: string, request: DescribeManualTaskInstanceRequest, headers: map[string]string, runtime: Util.RuntimeOptions): DescribeManualTaskInstanceResponse {
  Util.validateModel(request);
  var query : map[string]any = {};
  if (!Util.isUnset(request.workspaceId)) {
    query['workspaceId'] = request.workspaceId;
  }

  var req = new OpenApi.OpenApiRequest{ 
    headers = headers,
    query = OpenApiUtil.query(query),
  };
  var params = new OpenApi.Params{
    action = 'DescribeManualTaskInstance',
    version = '2024-04-30',
    protocol = 'HTTPS',
    pathname = `/dolphinscheduler/v3/projects/${OpenApiUtil.getEncodeParam(projectId)}/manualTaskInstances/${OpenApiUtil.getEncodeParam(manualTaskInstanceId)}`,
    method = 'GET',
    authType = 'AK',
    style = 'ROA',
    reqBodyType = 'json',
    bodyType = 'json',
  };
  if (Util.isUnset(@signatureVersion) || !Util.equalString(@signatureVersion, 'v4')) {
    return callApi(params, req, runtime);
  } else {
    return execute(params, req, runtime);
  }
}

/**
 * @summary 获取手动任务实例
 *
 * @param request DescribeManualTaskInstanceRequest
 * @return DescribeManualTaskInstanceResponse
 */
async function describeManualTaskInstance(manualTaskInstanceId: string, projectId: string, request: DescribeManualTaskInstanceRequest): DescribeManualTaskInstanceResponse {
  var runtime = new Util.RuntimeOptions{};
  var headers : map[string]string = {};
  return describeManualTaskInstanceWithOptions(manualTaskInstanceId, projectId, request, headers, runtime);
}

model DescribeProjectRequest {
  workspaceId?: string(name='workspaceId', description='This parameter is required.', example='1234'),
}

model DescribeProjectResponseBody = {
  description?: string(name='description', description='This parameter is required.', example='this is a project description'),
  name?: string(name='name', description='This parameter is required.', example='test_project_name'),
  projectId?: string(name='projectId', example='p-3q9jo749ne5****'),
  requestId?: string(name='requestId', example='B897B94B-6754-5D09-AB8C-2E8186CCADC0'),
}

model DescribeProjectResponse = {
  headers?: map[string]string(name='headers'),
  statusCode?: int32(name='statusCode'),
  body?: DescribeProjectResponseBody(name='body'),
}

/**
 * @summary 获取项目详情
 *
 * @param request DescribeProjectRequest
 * @param headers map
 * @param runtime runtime options for this request RuntimeOptions
 * @return DescribeProjectResponse
 */
async function describeProjectWithOptions(projectId: string, request: DescribeProjectRequest, headers: map[string]string, runtime: Util.RuntimeOptions): DescribeProjectResponse {
  Util.validateModel(request);
  var query : map[string]any = {};
  if (!Util.isUnset(request.workspaceId)) {
    query['workspaceId'] = request.workspaceId;
  }

  var req = new OpenApi.OpenApiRequest{ 
    headers = headers,
    query = OpenApiUtil.query(query),
  };
  var params = new OpenApi.Params{
    action = 'DescribeProject',
    version = '2024-04-30',
    protocol = 'HTTPS',
    pathname = `/dolphinscheduler/v3/projects/${OpenApiUtil.getEncodeParam(projectId)}`,
    method = 'GET',
    authType = 'AK',
    style = 'ROA',
    reqBodyType = 'json',
    bodyType = 'json',
  };
  if (Util.isUnset(@signatureVersion) || !Util.equalString(@signatureVersion, 'v4')) {
    return callApi(params, req, runtime);
  } else {
    return execute(params, req, runtime);
  }
}

/**
 * @summary 获取项目详情
 *
 * @param request DescribeProjectRequest
 * @return DescribeProjectResponse
 */
async function describeProject(projectId: string, request: DescribeProjectRequest): DescribeProjectResponse {
  var runtime = new Util.RuntimeOptions{};
  var headers : map[string]string = {};
  return describeProjectWithOptions(projectId, request, headers, runtime);
}

model DescribeTaskRequest {
  workspaceId?: string(name='workspaceId', description='This parameter is required.', example='123***'),
}

model DescribeTaskResponseBody = {
  createTime?: string(name='CreateTime', example='2024-03-27 00:00:00'),
  delayTime?: int32(name='DelayTime', example='0'),
  description?: string(name='Description', example='test'),
  failRetryInterval?: int32(name='FailRetryInterval', example='1'),
  failRetryTimes?: int32(name='FailRetryTimes', example='0'),
  flag?: string(name='Flag', example='YES'),
  projectId?: string(name='ProjectId', example='p-3q9jo749ne5****'),
  resourceIds?: string(name='ResourceIds', example='r-oy98v7n43el****'),
  taskId?: string(name='TaskId', example='t-3q9jo749ne5****'),
  taskName?: string(name='TaskName', example='test'),
  taskParams?: string(name='TaskParams', example='{
    "yarnUser": "",
    "conditionResult": "null",
    "rawScript": "sleep 300",
    "submitOnYarnFlag": false,
    "emrClusterId": "",
    "yarnPriority": "",
    "dependence": "null",
    "yarnMemory": "",
    "localParams": [],
    "switchResult": "null",
    "resourceList": [],
    "yarnQueue": "",
    "yarnVCores": "",
    "associateManualTaskFlag": false
}'),
  taskPriority?: string(name='TaskPriority', example='MEDIUM'),
  taskType?: string(name='TaskType', example='SHELL'),
  timeout?: int32(name='Timeout', example='10'),
  timeoutFlag?: string(name='TimeoutFlag', example='CLOSE'),
  timeoutNotifyStrategy?: string(name='TimeoutNotifyStrategy', example='WARN'),
  updateTime?: string(name='UpdateTime', example='2024-03-27 00:00:00'),
  version?: string(name='Version', example='1'),
  requestId?: string(name='requestId', description='Id of the request', example='DD6B1B2A-5837-5237-ABE4-FF0C8944****'),
}

model DescribeTaskResponse = {
  headers?: map[string]string(name='headers'),
  statusCode?: int32(name='statusCode'),
  body?: DescribeTaskResponseBody(name='body'),
}

/**
 * @summary 查询任务定义
 *
 * @param request DescribeTaskRequest
 * @param headers map
 * @param runtime runtime options for this request RuntimeOptions
 * @return DescribeTaskResponse
 */
async function describeTaskWithOptions(workflowId: string, projectId: string, taskId: string, request: DescribeTaskRequest, headers: map[string]string, runtime: Util.RuntimeOptions): DescribeTaskResponse {
  Util.validateModel(request);
  var query : map[string]any = {};
  if (!Util.isUnset(request.workspaceId)) {
    query['workspaceId'] = request.workspaceId;
  }

  var req = new OpenApi.OpenApiRequest{ 
    headers = headers,
    query = OpenApiUtil.query(query),
  };
  var params = new OpenApi.Params{
    action = 'DescribeTask',
    version = '2024-04-30',
    protocol = 'HTTPS',
    pathname = `/dolphinscheduler/v3/projects/${OpenApiUtil.getEncodeParam(projectId)}/workflows/${OpenApiUtil.getEncodeParam(workflowId)}/tasks/${OpenApiUtil.getEncodeParam(taskId)}`,
    method = 'GET',
    authType = 'AK',
    style = 'ROA',
    reqBodyType = 'json',
    bodyType = 'json',
  };
  if (Util.isUnset(@signatureVersion) || !Util.equalString(@signatureVersion, 'v4')) {
    return callApi(params, req, runtime);
  } else {
    return execute(params, req, runtime);
  }
}

/**
 * @summary 查询任务定义
 *
 * @param request DescribeTaskRequest
 * @return DescribeTaskResponse
 */
async function describeTask(workflowId: string, projectId: string, taskId: string, request: DescribeTaskRequest): DescribeTaskResponse {
  var runtime = new Util.RuntimeOptions{};
  var headers : map[string]string = {};
  return describeTaskWithOptions(workflowId, projectId, taskId, request, headers, runtime);
}

model DescribeTaskInstanceRequest {
  workspaceId?: string(name='workspaceId', description='This parameter is required.', example='123***'),
}

model DescribeTaskInstanceResponseBody = {
  dryRun?: string(name='DryRun', example='0'),
  emrClusterId?: string(name='EmrClusterId', example='c-b933c5aac7f7***'),
  endTime?: string(name='EndTime', example='2024-03-27 00:00:00'),
  externalAppId?: string(name='ExternalAppId', example='application_123_***'),
  resourceGroupId?: string(name='ResourceGroupId', example='wg-123abc***'),
  retryTimes?: int32(name='RetryTimes', example='0'),
  startTime?: string(name='StartTime', example='2024-03-27 00:00:00'),
  status?: string(name='Status', example='SUCCESS'),
  submitTime?: string(name='SubmitTime', example='2024-03-27 00:00:00'),
  taskId?: string(name='TaskId', example='t-3q9jo749ne5****'),
  taskInstanceId?: string(name='TaskInstanceId', example='ti-3q9jo749ne5****'),
  taskInstanceName?: string(name='TaskInstanceName', example='test'),
  taskParams?: string(name='TaskParams', example='{
    "yarnUser": "",
    "conditionResult": "null",
    "rawScript": "sleep 300",
    "submitOnYarnFlag": false,
    "emrClusterId": "",
    "yarnPriority": "",
    "dependence": "null",
    "yarnMemory": "",
    "localParams": [],
    "switchResult": "null",
    "resourceList": [],
    "yarnQueue": "",
    "yarnVCores": "",
    "associateManualTaskFlag": false
}'),
  taskType?: string(name='TaskType', example='SHELL'),
  taskVersion?: string(name='TaskVersion', example='1'),
  workflowInstanceId?: string(name='WorkflowInstanceId', example='wi-3q9jo749ne5****'),
  requestId?: string(name='requestId', description='Id of the request', example='DD6B1B2A-5837-5237-ABE4-FF0C8944****'),
}

model DescribeTaskInstanceResponse = {
  headers?: map[string]string(name='headers'),
  statusCode?: int32(name='statusCode'),
  body?: DescribeTaskInstanceResponseBody(name='body'),
}

/**
 * @summary 获取任务实例
 *
 * @param request DescribeTaskInstanceRequest
 * @param headers map
 * @param runtime runtime options for this request RuntimeOptions
 * @return DescribeTaskInstanceResponse
 */
async function describeTaskInstanceWithOptions(projectId: string, workflowInstanceId: string, taskInstanceId: string, request: DescribeTaskInstanceRequest, headers: map[string]string, runtime: Util.RuntimeOptions): DescribeTaskInstanceResponse {
  Util.validateModel(request);
  var query : map[string]any = {};
  if (!Util.isUnset(request.workspaceId)) {
    query['workspaceId'] = request.workspaceId;
  }

  var req = new OpenApi.OpenApiRequest{ 
    headers = headers,
    query = OpenApiUtil.query(query),
  };
  var params = new OpenApi.Params{
    action = 'DescribeTaskInstance',
    version = '2024-04-30',
    protocol = 'HTTPS',
    pathname = `/dolphinscheduler/v3/projects/${OpenApiUtil.getEncodeParam(projectId)}/workflows/${OpenApiUtil.getEncodeParam(workflowInstanceId)}/taskInstances/${OpenApiUtil.getEncodeParam(taskInstanceId)}`,
    method = 'GET',
    authType = 'AK',
    style = 'ROA',
    reqBodyType = 'json',
    bodyType = 'json',
  };
  if (Util.isUnset(@signatureVersion) || !Util.equalString(@signatureVersion, 'v4')) {
    return callApi(params, req, runtime);
  } else {
    return execute(params, req, runtime);
  }
}

/**
 * @summary 获取任务实例
 *
 * @param request DescribeTaskInstanceRequest
 * @return DescribeTaskInstanceResponse
 */
async function describeTaskInstance(projectId: string, workflowInstanceId: string, taskInstanceId: string, request: DescribeTaskInstanceRequest): DescribeTaskInstanceResponse {
  var runtime = new Util.RuntimeOptions{};
  var headers : map[string]string = {};
  return describeTaskInstanceWithOptions(projectId, workflowInstanceId, taskInstanceId, request, headers, runtime);
}

model DescribeWorkflowRequest {
  workspaceId?: string(name='workspaceId', description='This parameter is required.', example='12345'),
}

model DescribeWorkflowResponseBody = {
  requestId?: string(name='requestId', example='611AD6E6-BFE3-5897-AA12-569F79DBAF9B'),
  schedule?: {
    alertGroupId?: string(name='alertGroupId', example='ag-n72kong0832****'),
    alertStrategy?: string(name='alertStrategy', example='NONE'),
    cronExpr?: string(name='cronExpr', example='0 0 * * * ? *'),
    emrClusterId?: string(name='emrClusterId', example='C-15F7AB9B53F1****'),
    failureStrategy?: string(name='failureStrategy', example='END'),
    resourceGroupId?: string(name='resourceGroupId', example='wg-susqimrr649x****'),
    scheduleEndTime?: string(name='scheduleEndTime', example='2024-01-01 00:00:00'),
    scheduleStartTime?: string(name='scheduleStartTime', example='2024-01-01 00:00:00'),
    scheduleState?: string(name='scheduleState', example='OFFLINE'),
    timeZone?: string(name='timeZone', example='Asia/Shanghai'),
    workflowInstancePriority?: string(name='workflowInstancePriority', example='MEDIUM'),
  }(name='schedule'),
  taskRelations?: [ 
    {
      postTaskId?: string(name='postTaskId', example='t-n72kong0832****'),
      preTaskId?: string(name='preTaskId', example='t-n72kong0832****'),
    }
  ](name='taskRelations'),
  tasks?: [ 
    {
      description?: string(name='description', example='task description'),
      name?: string(name='name', example='task_name'),
      taskId?: string(name='taskId', example='t-n72kong0832****'),
      version?: int32(name='version', example='1'),
    }
  ](name='tasks'),
  workflow?: {
    createTime?: string(name='createTime', example='2024-01-01 00:00:00'),
    description?: string(name='description', example='test'),
    executionType?: string(name='executionType', example='PARALLEL'),
    name?: string(name='name', example='test'),
    parentDirectoryId?: string(name='parentDirectoryId', example='wd-n72kong0832****'),
    timeout?: int32(name='timeout', example='0'),
    updateTime?: string(name='updateTime', example='2024-01-01 00:00:00'),
    workflowId?: string(name='workflowId', example='w-n72kong0832****'),
    workflowParams?: string(name='workflowParams', example='[{"prop":"key1","value":"value1"}]'),
  }(name='workflow'),
}

model DescribeWorkflowResponse = {
  headers?: map[string]string(name='headers'),
  statusCode?: int32(name='statusCode'),
  body?: DescribeWorkflowResponseBody(name='body'),
}

/**
 * @summary 获取工作流详情
 *
 * @param request DescribeWorkflowRequest
 * @param headers map
 * @param runtime runtime options for this request RuntimeOptions
 * @return DescribeWorkflowResponse
 */
async function describeWorkflowWithOptions(projectId: string, workflowId: string, request: DescribeWorkflowRequest, headers: map[string]string, runtime: Util.RuntimeOptions): DescribeWorkflowResponse {
  Util.validateModel(request);
  var query : map[string]any = {};
  if (!Util.isUnset(request.workspaceId)) {
    query['workspaceId'] = request.workspaceId;
  }

  var req = new OpenApi.OpenApiRequest{ 
    headers = headers,
    query = OpenApiUtil.query(query),
  };
  var params = new OpenApi.Params{
    action = 'DescribeWorkflow',
    version = '2024-04-30',
    protocol = 'HTTPS',
    pathname = `/dolphinscheduler/v3/projects/${OpenApiUtil.getEncodeParam(projectId)}/workflows/${OpenApiUtil.getEncodeParam(workflowId)}`,
    method = 'GET',
    authType = 'AK',
    style = 'ROA',
    reqBodyType = 'json',
    bodyType = 'json',
  };
  if (Util.isUnset(@signatureVersion) || !Util.equalString(@signatureVersion, 'v4')) {
    return callApi(params, req, runtime);
  } else {
    return execute(params, req, runtime);
  }
}

/**
 * @summary 获取工作流详情
 *
 * @param request DescribeWorkflowRequest
 * @return DescribeWorkflowResponse
 */
async function describeWorkflow(projectId: string, workflowId: string, request: DescribeWorkflowRequest): DescribeWorkflowResponse {
  var runtime = new Util.RuntimeOptions{};
  var headers : map[string]string = {};
  return describeWorkflowWithOptions(projectId, workflowId, request, headers, runtime);
}

model DescribeWorkflowInstanceRequest {
  workspaceId?: string(name='workspaceId', description='This parameter is required.', example='12345'),
}

model DescribeWorkflowInstanceResponseBody = {
  alertGroupId?: string(name='alertGroupId', example='ag-n72kong0832****'),
  alertStrategy?: string(name='alertStrategy', example='NONE'),
  emrClusterId?: string(name='emrClusterId', example='c-047fa6bbe732****'),
  endTime?: string(name='endTime', example='2024-03-27 00:00:00'),
  failureStrategy?: string(name='failureStrategy', example='END'),
  isComplementData?: boolean(name='isComplementData', example='false'),
  name?: string(name='name', example='workflow_instance_name'),
  requestId?: string(name='requestId', example='DD6B1B2A-5837-5237-ABE4-FF0C8944****'),
  resourceGroupId?: string(name='resourceGroupId', example='wg-susqimrr649x****'),
  restartTime?: string(name='restartTime', example='2024-03-27 00:00:00'),
  runTimes?: int32(name='runTimes', example='1'),
  scheduleTime?: string(name='scheduleTime', example='2024-03-27 00:00:00'),
  startTime?: string(name='startTime', example='2024-03-27 00:00:00'),
  status?: string(name='status', example='SUCCESS'),
  timeout?: int32(name='timeout', example='0'),
  workflowId?: string(name='workflowId', example='w-3q9jo749ne5****'),
  workflowInstanceId?: string(name='workflowInstanceId', example='wi-3q9jo749ne5****'),
  workflowInstancePriority?: string(name='workflowInstancePriority', example='MEDIUM'),
  workflowVersion?: int32(name='workflowVersion', example='1'),
}

model DescribeWorkflowInstanceResponse = {
  headers?: map[string]string(name='headers'),
  statusCode?: int32(name='statusCode'),
  body?: DescribeWorkflowInstanceResponseBody(name='body'),
}

/**
 * @summary 获取工作流实例详情
 *
 * @param request DescribeWorkflowInstanceRequest
 * @param headers map
 * @param runtime runtime options for this request RuntimeOptions
 * @return DescribeWorkflowInstanceResponse
 */
async function describeWorkflowInstanceWithOptions(projectId: string, workflowInstanceId: string, request: DescribeWorkflowInstanceRequest, headers: map[string]string, runtime: Util.RuntimeOptions): DescribeWorkflowInstanceResponse {
  Util.validateModel(request);
  var query : map[string]any = {};
  if (!Util.isUnset(request.workspaceId)) {
    query['workspaceId'] = request.workspaceId;
  }

  var req = new OpenApi.OpenApiRequest{ 
    headers = headers,
    query = OpenApiUtil.query(query),
  };
  var params = new OpenApi.Params{
    action = 'DescribeWorkflowInstance',
    version = '2024-04-30',
    protocol = 'HTTPS',
    pathname = `/dolphinscheduler/v3/projects/${OpenApiUtil.getEncodeParam(projectId)}/workflowInstances/${OpenApiUtil.getEncodeParam(workflowInstanceId)}`,
    method = 'GET',
    authType = 'AK',
    style = 'ROA',
    reqBodyType = 'json',
    bodyType = 'json',
  };
  if (Util.isUnset(@signatureVersion) || !Util.equalString(@signatureVersion, 'v4')) {
    return callApi(params, req, runtime);
  } else {
    return execute(params, req, runtime);
  }
}

/**
 * @summary 获取工作流实例详情
 *
 * @param request DescribeWorkflowInstanceRequest
 * @return DescribeWorkflowInstanceResponse
 */
async function describeWorkflowInstance(projectId: string, workflowInstanceId: string, request: DescribeWorkflowInstanceRequest): DescribeWorkflowInstanceResponse {
  var runtime = new Util.RuntimeOptions{};
  var headers : map[string]string = {};
  return describeWorkflowInstanceWithOptions(projectId, workflowInstanceId, request, headers, runtime);
}

model ListAlertGroupsRequest {
  maxResults?: int32(name='maxResults', example='10'),
  nextToken?: string(name='nextToken', example='0'),
  searchVal?: string(name='searchVal', example='name'),
  workspaceId?: string(name='workspaceId', description='This parameter is required.', example='w-lxyy60mpgpg****'),
}

model ListAlertGroupsResponseBody = {
  data?: [ 
    {
      alertGroupId?: string(name='alertGroupId', example='ag-8mklwpevk74****'),
      alertInstanceIds?: string(name='alertInstanceIds', example='50'),
      createTime?: long(name='createTime', example='1726834240000'),
      description?: string(name='description', example='description'),
      groupName?: string(name='groupName', example='name'),
      updateTime?: long(name='updateTime', example='1726834240000'),
    }
  ](name='data'),
  maxResults?: int32(name='maxResults', example='10'),
  nextToken?: string(name='nextToken', example='0'),
  requestId?: string(name='requestId', description='Id of the request', example='DD6B1B2A-5837-5237-ABE4-FF0C8944****'),
  totalCount?: int32(name='totalCount', example='10'),
}

model ListAlertGroupsResponse = {
  headers?: map[string]string(name='headers'),
  statusCode?: int32(name='statusCode'),
  body?: ListAlertGroupsResponseBody(name='body'),
}

/**
 * @summary 查询告警组列表
 *
 * @param request ListAlertGroupsRequest
 * @param headers map
 * @param runtime runtime options for this request RuntimeOptions
 * @return ListAlertGroupsResponse
 */
async function listAlertGroupsWithOptions(projectId: string, request: ListAlertGroupsRequest, headers: map[string]string, runtime: Util.RuntimeOptions): ListAlertGroupsResponse {
  Util.validateModel(request);
  var query : map[string]any = {};
  if (!Util.isUnset(request.maxResults)) {
    query['maxResults'] = request.maxResults;
  }
  if (!Util.isUnset(request.nextToken)) {
    query['nextToken'] = request.nextToken;
  }
  if (!Util.isUnset(request.searchVal)) {
    query['searchVal'] = request.searchVal;
  }
  if (!Util.isUnset(request.workspaceId)) {
    query['workspaceId'] = request.workspaceId;
  }

  var req = new OpenApi.OpenApiRequest{ 
    headers = headers,
    query = OpenApiUtil.query(query),
  };
  var params = new OpenApi.Params{
    action = 'ListAlertGroups',
    version = '2024-04-30',
    protocol = 'HTTPS',
    pathname = `/dolphinscheduler/v3/alert-groups`,
    method = 'GET',
    authType = 'AK',
    style = 'ROA',
    reqBodyType = 'json',
    bodyType = 'json',
  };
  if (Util.isUnset(@signatureVersion) || !Util.equalString(@signatureVersion, 'v4')) {
    return callApi(params, req, runtime);
  } else {
    return execute(params, req, runtime);
  }
}

/**
 * @summary 查询告警组列表
 *
 * @param request ListAlertGroupsRequest
 * @return ListAlertGroupsResponse
 */
async function listAlertGroups(projectId: string, request: ListAlertGroupsRequest): ListAlertGroupsResponse {
  var runtime = new Util.RuntimeOptions{};
  var headers : map[string]string = {};
  return listAlertGroupsWithOptions(projectId, request, headers, runtime);
}

model ListManualTaskInstancesRequest {
  endTime?: string(name='endTime', example='2024-03-27 00:00:00'),
  maxResults?: int32(name='maxResults', example='10'),
  nextToken?: string(name='nextToken', example='123abc***'),
  searchVal?: string(name='searchVal', example='test'),
  startTime?: string(name='startTime', example='2024-03-27 00:00:00'),
  status?: string(name='status', example='SUCCESS'),
  workspaceId?: string(name='workspaceId', description='This parameter is required.', example='123***'),
}

model ListManualTaskInstancesResponseBody = {
  data?: [ 
    {
      emrClusterId?: string(name='EmrClusterId', example='c-b933c5aac7f7***'),
      endTime?: string(name='EndTime', example='2024-03-27 00:00:00'),
      externalAppId?: string(name='ExternalAppId', example='application_123_***'),
      manualTaskInstanceId?: string(name='ManualTaskInstanceId', example='mti-3q9jo749ne5****'),
      manualTaskInstanceName?: string(name='ManualTaskInstanceName', example='test'),
      resourceGroupId?: string(name='ResourceGroupId', example='wg-3q9jo749ne5****'),
      startTime?: string(name='StartTime', example='2024-03-27 00:00:00'),
      status?: string(name='Status', example='SUCCESS'),
      submitTime?: string(name='SubmitTime', example='2024-03-27 00:00:00'),
      taskParams?: string(name='TaskParams', example='{
    "yarnUser": "",
    "conditionResult": "null",
    "rawScript": "sleep 300",
    "submitOnYarnFlag": false,
    "emrClusterId": "",
    "yarnPriority": "",
    "dependence": "null",
    "yarnMemory": "",
    "localParams": [],
    "switchResult": "null",
    "resourceList": [],
    "yarnQueue": "",
    "yarnVCores": "",
    "associateManualTaskFlag": false
}'),
      taskType?: string(name='TaskType', example='SHELL'),
    }
  ](name='data'),
  nextToken?: string(name='nextToken', example='123abc***'),
  requestId?: string(name='requestId', description='Id of the request', example='DD6B1B2A-5837-5237-ABE4-FF0C8944****'),
  totalSize?: int32(name='totalSize', example='10'),
}

model ListManualTaskInstancesResponse = {
  headers?: map[string]string(name='headers'),
  statusCode?: int32(name='statusCode'),
  body?: ListManualTaskInstancesResponseBody(name='body'),
}

/**
 * @summary 获取手动任务实例列表
 *
 * @param request ListManualTaskInstancesRequest
 * @param headers map
 * @param runtime runtime options for this request RuntimeOptions
 * @return ListManualTaskInstancesResponse
 */
async function listManualTaskInstancesWithOptions(projectId: string, request: ListManualTaskInstancesRequest, headers: map[string]string, runtime: Util.RuntimeOptions): ListManualTaskInstancesResponse {
  Util.validateModel(request);
  var query : map[string]any = {};
  if (!Util.isUnset(request.endTime)) {
    query['endTime'] = request.endTime;
  }
  if (!Util.isUnset(request.maxResults)) {
    query['maxResults'] = request.maxResults;
  }
  if (!Util.isUnset(request.nextToken)) {
    query['nextToken'] = request.nextToken;
  }
  if (!Util.isUnset(request.searchVal)) {
    query['searchVal'] = request.searchVal;
  }
  if (!Util.isUnset(request.startTime)) {
    query['startTime'] = request.startTime;
  }
  if (!Util.isUnset(request.status)) {
    query['status'] = request.status;
  }
  if (!Util.isUnset(request.workspaceId)) {
    query['workspaceId'] = request.workspaceId;
  }

  var req = new OpenApi.OpenApiRequest{ 
    headers = headers,
    query = OpenApiUtil.query(query),
  };
  var params = new OpenApi.Params{
    action = 'ListManualTaskInstances',
    version = '2024-04-30',
    protocol = 'HTTPS',
    pathname = `/dolphinscheduler/v3/projects/${OpenApiUtil.getEncodeParam(projectId)}/manualTaskInstances`,
    method = 'GET',
    authType = 'AK',
    style = 'ROA',
    reqBodyType = 'json',
    bodyType = 'json',
  };
  if (Util.isUnset(@signatureVersion) || !Util.equalString(@signatureVersion, 'v4')) {
    return callApi(params, req, runtime);
  } else {
    return execute(params, req, runtime);
  }
}

/**
 * @summary 获取手动任务实例列表
 *
 * @param request ListManualTaskInstancesRequest
 * @return ListManualTaskInstancesResponse
 */
async function listManualTaskInstances(projectId: string, request: ListManualTaskInstancesRequest): ListManualTaskInstancesResponse {
  var runtime = new Util.RuntimeOptions{};
  var headers : map[string]string = {};
  return listManualTaskInstancesWithOptions(projectId, request, headers, runtime);
}

model ListManualTasksRequest {
  maxResults?: int32(name='maxResults', example='10'),
  nextToken?: string(name='nextToken', example='123abc***'),
  searchVal?: string(name='searchVal', example='test'),
  taskType?: string(name='taskType', example='SHELL'),
  workspaceId?: string(name='workspaceId', description='This parameter is required.', example='123***'),
}

model ListManualTasksResponseBody = {
  data?: [ 
    {
      createTime?: string(name='CreateTime', example='2024-03-27 00:00:00'),
      description?: string(name='Description', example='test'),
      manualTaskId?: string(name='ManualTaskId', example='mt-3q9jo749ne5****'),
      manualTaskName?: string(name='ManualTaskName', example='test'),
      parentDirectoryId?: string(name='ParentDirectoryId', example='mtd-oy98v7n43el****'),
      projectId?: string(name='ProjectId', example='p-3q9jo749ne5****'),
      resourceIds?: string(name='ResourceIds', example='r-oy98v7n43el****'),
      taskParams?: string(name='TaskParams', example='{
    "yarnUser": "",
    "conditionResult": "null",
    "rawScript": "sleep 300",
    "submitOnYarnFlag": false,
    "emrClusterId": "",
    "yarnPriority": "",
    "dependence": "null",
    "yarnMemory": "",
    "localParams": [],
    "switchResult": "null",
    "resourceList": [],
    "yarnQueue": "",
    "yarnVCores": "",
    "associateManualTaskFlag": false
}'),
      taskType?: string(name='TaskType', example='SHELL'),
      updateTime?: string(name='UpdateTime', example='2024-03-27 00:00:00'),
    }
  ](name='data'),
  nextToken?: string(name='nextToken', example='123abc***'),
  requestId?: string(name='requestId', description='Id of the request', example='DD6B1B2A-5837-5237-ABE4-FF0C8944****'),
  totalSize?: int32(name='totalSize', example='10'),
}

model ListManualTasksResponse = {
  headers?: map[string]string(name='headers'),
  statusCode?: int32(name='statusCode'),
  body?: ListManualTasksResponseBody(name='body'),
}

/**
 * @summary 查询手动任务定义列表
 *
 * @param request ListManualTasksRequest
 * @param headers map
 * @param runtime runtime options for this request RuntimeOptions
 * @return ListManualTasksResponse
 */
async function listManualTasksWithOptions(projectId: string, request: ListManualTasksRequest, headers: map[string]string, runtime: Util.RuntimeOptions): ListManualTasksResponse {
  Util.validateModel(request);
  var query : map[string]any = {};
  if (!Util.isUnset(request.maxResults)) {
    query['maxResults'] = request.maxResults;
  }
  if (!Util.isUnset(request.nextToken)) {
    query['nextToken'] = request.nextToken;
  }
  if (!Util.isUnset(request.searchVal)) {
    query['searchVal'] = request.searchVal;
  }
  if (!Util.isUnset(request.taskType)) {
    query['taskType'] = request.taskType;
  }
  if (!Util.isUnset(request.workspaceId)) {
    query['workspaceId'] = request.workspaceId;
  }

  var req = new OpenApi.OpenApiRequest{ 
    headers = headers,
    query = OpenApiUtil.query(query),
  };
  var params = new OpenApi.Params{
    action = 'ListManualTasks',
    version = '2024-04-30',
    protocol = 'HTTPS',
    pathname = `/dolphinscheduler/v3/projects/${OpenApiUtil.getEncodeParam(projectId)}/manualTasks`,
    method = 'GET',
    authType = 'AK',
    style = 'ROA',
    reqBodyType = 'json',
    bodyType = 'json',
  };
  if (Util.isUnset(@signatureVersion) || !Util.equalString(@signatureVersion, 'v4')) {
    return callApi(params, req, runtime);
  } else {
    return execute(params, req, runtime);
  }
}

/**
 * @summary 查询手动任务定义列表
 *
 * @param request ListManualTasksRequest
 * @return ListManualTasksResponse
 */
async function listManualTasks(projectId: string, request: ListManualTasksRequest): ListManualTasksResponse {
  var runtime = new Util.RuntimeOptions{};
  var headers : map[string]string = {};
  return listManualTasksWithOptions(projectId, request, headers, runtime);
}

model ListProjectsRequest {
  maxResults?: int32(name='maxResults', example='10'),
  nextToken?: string(name='nextToken', example='123abc***'),
  searchVal?: string(name='searchVal', example='test'),
  workspaceId?: string(name='workspaceId', description='This parameter is required.', example='12345'),
}

model ListProjectsResponseBody = {
  data?: [ 
    {
      description?: string(name='description', example='test'),
      name?: string(name='name', example='project_name'),
      projectId?: string(name='projectId', example='p-3q9jo749ne5****'),
    }
  ](name='data'),
  nextToken?: string(name='nextToken', example='123abc***'),
  requestId?: string(name='requestId', example='DD6B1B2A-5837-5237-ABE4-FF0C8944****'),
  totalSize?: int32(name='totalSize', example='10'),
}

model ListProjectsResponse = {
  headers?: map[string]string(name='headers'),
  statusCode?: int32(name='statusCode'),
  body?: ListProjectsResponseBody(name='body'),
}

/**
 * @summary 获取项目详情
 *
 * @param request ListProjectsRequest
 * @param headers map
 * @param runtime runtime options for this request RuntimeOptions
 * @return ListProjectsResponse
 */
async function listProjectsWithOptions(request: ListProjectsRequest, headers: map[string]string, runtime: Util.RuntimeOptions): ListProjectsResponse {
  Util.validateModel(request);
  var query : map[string]any = {};
  if (!Util.isUnset(request.maxResults)) {
    query['maxResults'] = request.maxResults;
  }
  if (!Util.isUnset(request.nextToken)) {
    query['nextToken'] = request.nextToken;
  }
  if (!Util.isUnset(request.searchVal)) {
    query['searchVal'] = request.searchVal;
  }
  if (!Util.isUnset(request.workspaceId)) {
    query['workspaceId'] = request.workspaceId;
  }

  var req = new OpenApi.OpenApiRequest{ 
    headers = headers,
    query = OpenApiUtil.query(query),
  };
  var params = new OpenApi.Params{
    action = 'ListProjects',
    version = '2024-04-30',
    protocol = 'HTTPS',
    pathname = `/dolphinscheduler/v3/projects`,
    method = 'GET',
    authType = 'AK',
    style = 'ROA',
    reqBodyType = 'json',
    bodyType = 'json',
  };
  if (Util.isUnset(@signatureVersion) || !Util.equalString(@signatureVersion, 'v4')) {
    return callApi(params, req, runtime);
  } else {
    return execute(params, req, runtime);
  }
}

/**
 * @summary 获取项目详情
 *
 * @param request ListProjectsRequest
 * @return ListProjectsResponse
 */
async function listProjects(request: ListProjectsRequest): ListProjectsResponse {
  var runtime = new Util.RuntimeOptions{};
  var headers : map[string]string = {};
  return listProjectsWithOptions(request, headers, runtime);
}

model ListResourceGroupsRequest {
  maxResults?: int32(name='maxResults', example='10'),
  nextToken?: string(name='nextToken', example='0'),
  resourceGroupName?: string(name='resourceGroupName', example='name'),
  resourceGroupType?: string(name='resourceGroupType', example='CLUSTER_RESOURCE_GROUP'),
  workspaceId?: string(name='workspaceId', description='This parameter is required.', example='w-lxyy60mpgpg****'),
}

model ListResourceGroupsResponseBody = {
  data?: [ 
    {
      associatedClusterTemplates?: [ 
        {
          clusterType?: string(name='clusterType'),
          templateId?: string(name='templateId', example='78723f0dc36。'),
          templateName?: string(name='templateName'),
        }
      ](name='associatedClusterTemplates'),
      associatedClusters?: [ 
        {
          clusterId?: string(name='clusterId', example='c-3cd8ba94b36cxxxx'),
          clusterName?: string(name='clusterName'),
          clusterType?: string(name='clusterType'),
        }
      ](name='associatedClusters'),
      associatedWorkspaces?: [ 
        {
          workspaceId?: string(name='workspaceId', example='1200827。'),
          workspaceName?: string(name='workspaceName'),
        }
      ](name='associatedWorkspaces'),
      createTime?: string(name='createTime', example='2024-09-26T02:10:04Z'),
      nodeMaxCount?: int32(name='nodeMaxCount', example='2。'),
      nodeMinCount?: int32(name='nodeMinCount', example='1。'),
      nodeType?: string(name='nodeType', example='EMR_W1_SMALL。'),
      paymentType?: string(name='paymentType', example='postpaid'),
      resourceGroupId?: string(name='resourceGroupId', example='rg-acfm4ewqrznxxxx'),
      resourceGroupName?: string(name='resourceGroupName'),
      resourceGroupType?: string(name='resourceGroupType', example='CLUSTER_RESOURCE_GROUP。'),
    }
  ](name='data'),
  maxResults?: int32(name='maxResults', example='10。'),
  nextToken?: string(name='nextToken', example='1。'),
  requestId?: string(name='requestId', description='Id of the request', example='DD6B1B2A-5837-5237-ABE4-FF0C8944****'),
  totalCount?: int32(name='totalCount', example='16'),
}

model ListResourceGroupsResponse = {
  headers?: map[string]string(name='headers'),
  statusCode?: int32(name='statusCode'),
  body?: ListResourceGroupsResponseBody(name='body'),
}

/**
 * @summary 查询调度资源组列表
 *
 * @param request ListResourceGroupsRequest
 * @param headers map
 * @param runtime runtime options for this request RuntimeOptions
 * @return ListResourceGroupsResponse
 */
async function listResourceGroupsWithOptions(request: ListResourceGroupsRequest, headers: map[string]string, runtime: Util.RuntimeOptions): ListResourceGroupsResponse {
  Util.validateModel(request);
  var query : map[string]any = {};
  if (!Util.isUnset(request.maxResults)) {
    query['maxResults'] = request.maxResults;
  }
  if (!Util.isUnset(request.nextToken)) {
    query['nextToken'] = request.nextToken;
  }
  if (!Util.isUnset(request.resourceGroupName)) {
    query['resourceGroupName'] = request.resourceGroupName;
  }
  if (!Util.isUnset(request.resourceGroupType)) {
    query['resourceGroupType'] = request.resourceGroupType;
  }
  if (!Util.isUnset(request.workspaceId)) {
    query['workspaceId'] = request.workspaceId;
  }

  var req = new OpenApi.OpenApiRequest{ 
    headers = headers,
    query = OpenApiUtil.query(query),
  };
  var params = new OpenApi.Params{
    action = 'ListResourceGroups',
    version = '2024-04-30',
    protocol = 'HTTPS',
    pathname = `/dolphinscheduler/v3/resourcegroups`,
    method = 'GET',
    authType = 'AK',
    style = 'ROA',
    reqBodyType = 'json',
    bodyType = 'json',
  };
  if (Util.isUnset(@signatureVersion) || !Util.equalString(@signatureVersion, 'v4')) {
    return callApi(params, req, runtime);
  } else {
    return execute(params, req, runtime);
  }
}

/**
 * @summary 查询调度资源组列表
 *
 * @param request ListResourceGroupsRequest
 * @return ListResourceGroupsResponse
 */
async function listResourceGroups(request: ListResourceGroupsRequest): ListResourceGroupsResponse {
  var runtime = new Util.RuntimeOptions{};
  var headers : map[string]string = {};
  return listResourceGroupsWithOptions(request, headers, runtime);
}

model ListTaskInstancesRequest {
  endTime?: string(name='endTime', example='2024-03-27 00:00:00'),
  maxResults?: int32(name='maxResults', example='10'),
  nextToken?: string(name='nextToken', example='123abc***'),
  searchVal?: string(name='searchVal', example='test'),
  startTime?: string(name='startTime', example='2024-03-27 00:00:00'),
  status?: string(name='status', example='SUCCESS'),
  workflowInstanceId?: string(name='workflowInstanceId', example='wi-3q9jo749ne5****'),
  workspaceId?: string(name='workspaceId', description='This parameter is required.', example='123***'),
}

model ListTaskInstancesResponseBody = {
  data?: [ 
    {
      dryRun?: string(name='DryRun', example='0'),
      emrClusterId?: string(name='EmrClusterId', example='c-b933c5aac7f7***'),
      endTime?: string(name='EndTime', example='2024-03-27 00:00:00'),
      externalAppId?: string(name='ExternalAppId', example='application_123_***'),
      resourceGroupId?: string(name='ResourceGroupId', example='wg-3q9jo749ne5****'),
      retryTimes?: int32(name='RetryTimes', example='0'),
      startTime?: string(name='StartTime', example='2024-03-27 00:00:00'),
      status?: string(name='Status', example='SUCCESS'),
      submitTime?: string(name='SubmitTime', example='2024-03-27 00:00:00'),
      taskId?: string(name='TaskId', example='t-3q9jo749ne5****'),
      taskInstanceId?: string(name='TaskInstanceId', example='ti-3q9jo749ne5****'),
      taskInstanceName?: string(name='TaskInstanceName', example='test'),
      taskParams?: string(name='TaskParams', example='{
    "yarnUser": "",
    "conditionResult": "null",
    "rawScript": "sleep 300",
    "submitOnYarnFlag": false,
    "emrClusterId": "",
    "yarnPriority": "",
    "dependence": "null",
    "yarnMemory": "",
    "localParams": [],
    "switchResult": "null",
    "resourceList": [],
    "yarnQueue": "",
    "yarnVCores": "",
    "associateManualTaskFlag": false
}'),
      taskType?: string(name='TaskType', example='SHELL'),
      taskVersion?: string(name='TaskVersion', example='1'),
      workflowInstanceId?: string(name='WorkflowInstanceId', example='wi-3q9jo749ne5****'),
    }
  ](name='data'),
  nextToken?: string(name='nextToken', example='123abc***'),
  requestId?: string(name='requestId', description='Id of the request', example='9E3A7161-EB7B-172B-8D18-FFB06BA38***'),
  totalSize?: int32(name='totalSize', example='10'),
}

model ListTaskInstancesResponse = {
  headers?: map[string]string(name='headers'),
  statusCode?: int32(name='statusCode'),
  body?: ListTaskInstancesResponseBody(name='body'),
}

/**
 * @summary 获取任务实例列表
 *
 * @param request ListTaskInstancesRequest
 * @param headers map
 * @param runtime runtime options for this request RuntimeOptions
 * @return ListTaskInstancesResponse
 */
async function listTaskInstancesWithOptions(projectId: string, request: ListTaskInstancesRequest, headers: map[string]string, runtime: Util.RuntimeOptions): ListTaskInstancesResponse {
  Util.validateModel(request);
  var query : map[string]any = {};
  if (!Util.isUnset(request.endTime)) {
    query['endTime'] = request.endTime;
  }
  if (!Util.isUnset(request.maxResults)) {
    query['maxResults'] = request.maxResults;
  }
  if (!Util.isUnset(request.nextToken)) {
    query['nextToken'] = request.nextToken;
  }
  if (!Util.isUnset(request.searchVal)) {
    query['searchVal'] = request.searchVal;
  }
  if (!Util.isUnset(request.startTime)) {
    query['startTime'] = request.startTime;
  }
  if (!Util.isUnset(request.status)) {
    query['status'] = request.status;
  }
  if (!Util.isUnset(request.workflowInstanceId)) {
    query['workflowInstanceId'] = request.workflowInstanceId;
  }
  if (!Util.isUnset(request.workspaceId)) {
    query['workspaceId'] = request.workspaceId;
  }

  var req = new OpenApi.OpenApiRequest{ 
    headers = headers,
    query = OpenApiUtil.query(query),
  };
  var params = new OpenApi.Params{
    action = 'ListTaskInstances',
    version = '2024-04-30',
    protocol = 'HTTPS',
    pathname = `/dolphinscheduler/v3/projects/${OpenApiUtil.getEncodeParam(projectId)}/taskInstances`,
    method = 'GET',
    authType = 'AK',
    style = 'ROA',
    reqBodyType = 'json',
    bodyType = 'json',
  };
  if (Util.isUnset(@signatureVersion) || !Util.equalString(@signatureVersion, 'v4')) {
    return callApi(params, req, runtime);
  } else {
    return execute(params, req, runtime);
  }
}

/**
 * @summary 获取任务实例列表
 *
 * @param request ListTaskInstancesRequest
 * @return ListTaskInstancesResponse
 */
async function listTaskInstances(projectId: string, request: ListTaskInstancesRequest): ListTaskInstancesResponse {
  var runtime = new Util.RuntimeOptions{};
  var headers : map[string]string = {};
  return listTaskInstancesWithOptions(projectId, request, headers, runtime);
}

model ListTasksRequest {
  maxResults?: string(name='maxResults', example='10'),
  nextToken?: string(name='nextToken', example='123abc***'),
  searchVal?: string(name='searchVal', example='test'),
  taskType?: string(name='taskType', example='SHELL'),
  workflowId?: string(name='workflowId', example='w-n72kong0832****'),
  workspaceId?: string(name='workspaceId', description='This parameter is required.', example='123***'),
}

model ListTasksResponseBody = {
  data?: [ 
    {
      createTime?: string(name='CreateTime', example='2024-03-27 00:00:00'),
      delayTime?: int32(name='DelayTime', example='0'),
      description?: string(name='Description', example='test'),
      failRetryInterval?: int32(name='FailRetryInterval', example='1'),
      failRetryTimes?: int32(name='FailRetryTimes', example='0'),
      flag?: string(name='Flag', example='YES'),
      projectId?: string(name='ProjectId', example='p-3q9jo749ne5****'),
      resourceIds?: string(name='ResourceIds', example='r-3q9jo749ne5****'),
      taskId?: string(name='TaskId', example='t-3q9jo749ne5****'),
      taskName?: string(name='TaskName', example='test'),
      taskParams?: string(name='TaskParams', example='{
    "yarnUser": "",
    "conditionResult": "null",
    "rawScript": "sleep 300",
    "submitOnYarnFlag": false,
    "emrClusterId": "",
    "yarnPriority": "",
    "dependence": "null",
    "yarnMemory": "",
    "localParams": [],
    "switchResult": "null",
    "resourceList": [],
    "yarnQueue": "",
    "yarnVCores": "",
    "associateManualTaskFlag": false
}'),
      taskPriority?: string(name='TaskPriority', example='MEDIUM'),
      taskType?: string(name='TaskType', example='SHELL'),
      timeout?: int32(name='Timeout', example='0'),
      timeoutFlag?: string(name='TimeoutFlag', example='CLOSE'),
      timeoutNotifyStrategy?: string(name='TimeoutNotifyStrategy', example='WARN'),
      updateTime?: string(name='UpdateTime', example='2024-03-27 00:00:00'),
      version?: string(name='Version', example='1'),
    }
  ](name='data'),
  nextToken?: string(name='nextToken', example='123abc***'),
  requestId?: string(name='requestId', description='Id of the request', example='DD6B1B2A-5837-5237-ABE4-FF0C8944****'),
  totalSize?: int32(name='totalSize', example='10'),
}

model ListTasksResponse = {
  headers?: map[string]string(name='headers'),
  statusCode?: int32(name='statusCode'),
  body?: ListTasksResponseBody(name='body'),
}

/**
 * @summary 查询任务定义列表
 *
 * @param request ListTasksRequest
 * @param headers map
 * @param runtime runtime options for this request RuntimeOptions
 * @return ListTasksResponse
 */
async function listTasksWithOptions(projectId: string, request: ListTasksRequest, headers: map[string]string, runtime: Util.RuntimeOptions): ListTasksResponse {
  Util.validateModel(request);
  var query : map[string]any = {};
  if (!Util.isUnset(request.maxResults)) {
    query['maxResults'] = request.maxResults;
  }
  if (!Util.isUnset(request.nextToken)) {
    query['nextToken'] = request.nextToken;
  }
  if (!Util.isUnset(request.searchVal)) {
    query['searchVal'] = request.searchVal;
  }
  if (!Util.isUnset(request.taskType)) {
    query['taskType'] = request.taskType;
  }
  if (!Util.isUnset(request.workflowId)) {
    query['workflowId'] = request.workflowId;
  }
  if (!Util.isUnset(request.workspaceId)) {
    query['workspaceId'] = request.workspaceId;
  }

  var req = new OpenApi.OpenApiRequest{ 
    headers = headers,
    query = OpenApiUtil.query(query),
  };
  var params = new OpenApi.Params{
    action = 'ListTasks',
    version = '2024-04-30',
    protocol = 'HTTPS',
    pathname = `/dolphinscheduler/v3/projects/${OpenApiUtil.getEncodeParam(projectId)}/tasks`,
    method = 'GET',
    authType = 'AK',
    style = 'ROA',
    reqBodyType = 'json',
    bodyType = 'json',
  };
  if (Util.isUnset(@signatureVersion) || !Util.equalString(@signatureVersion, 'v4')) {
    return callApi(params, req, runtime);
  } else {
    return execute(params, req, runtime);
  }
}

/**
 * @summary 查询任务定义列表
 *
 * @param request ListTasksRequest
 * @return ListTasksResponse
 */
async function listTasks(projectId: string, request: ListTasksRequest): ListTasksResponse {
  var runtime = new Util.RuntimeOptions{};
  var headers : map[string]string = {};
  return listTasksWithOptions(projectId, request, headers, runtime);
}

model ListWorkflowDirectoriesRequest {
  directoryId?: string(name='directoryId', example='wd-y98v7non5dx****'),
  maxResults?: int32(name='maxResults', example='10'),
  nextToken?: string(name='nextToken', example='0'),
  parentDirectoryId?: string(name='parentDirectoryId', example='wd-y98v7non5d****'),
  workspaceId?: string(name='workspaceId', description='This parameter is required.', example='12345'),
}

model ListWorkflowDirectoriesResponseBody = {
  data?: [ 
    {
      directoryId?: string(name='directoryId', example='wd-y98v7non5dx****'),
      name?: string(name='name', example='目录名称。'),
      parentDirectoryId?: string(name='parentDirectoryId', example='wd-y98v7non5dx****'),
      projectId?: string(name='projectId', example='p-v7n28j0m4ol****'),
      workflowId?: string(name='workflowId', example='w-lxyy60mpgpg****'),
    }
  ](name='data'),
  maxResults?: string(name='maxResults', example='10'),
  nextToken?: string(name='nextToken', example='1'),
  requestId?: string(name='requestId', description='Id of the request', example='DD6B1B2A-5837-5237-ABE4-FF0C8944****'),
  totalCount?: int32(name='totalCount', example='10'),
}

model ListWorkflowDirectoriesResponse = {
  headers?: map[string]string(name='headers'),
  statusCode?: int32(name='statusCode'),
  body?: ListWorkflowDirectoriesResponseBody(name='body'),
}

/**
 * @summary 查询工作流目录列表
 *
 * @param request ListWorkflowDirectoriesRequest
 * @param headers map
 * @param runtime runtime options for this request RuntimeOptions
 * @return ListWorkflowDirectoriesResponse
 */
async function listWorkflowDirectoriesWithOptions(projectId: string, request: ListWorkflowDirectoriesRequest, headers: map[string]string, runtime: Util.RuntimeOptions): ListWorkflowDirectoriesResponse {
  Util.validateModel(request);
  var query : map[string]any = {};
  if (!Util.isUnset(request.directoryId)) {
    query['directoryId'] = request.directoryId;
  }
  if (!Util.isUnset(request.maxResults)) {
    query['maxResults'] = request.maxResults;
  }
  if (!Util.isUnset(request.nextToken)) {
    query['nextToken'] = request.nextToken;
  }
  if (!Util.isUnset(request.parentDirectoryId)) {
    query['parentDirectoryId'] = request.parentDirectoryId;
  }
  if (!Util.isUnset(request.workspaceId)) {
    query['workspaceId'] = request.workspaceId;
  }

  var req = new OpenApi.OpenApiRequest{ 
    headers = headers,
    query = OpenApiUtil.query(query),
  };
  var params = new OpenApi.Params{
    action = 'ListWorkflowDirectories',
    version = '2024-04-30',
    protocol = 'HTTPS',
    pathname = `/dolphinscheduler/v3/projects/${OpenApiUtil.getEncodeParam(projectId)}/directories`,
    method = 'GET',
    authType = 'AK',
    style = 'ROA',
    reqBodyType = 'json',
    bodyType = 'json',
  };
  if (Util.isUnset(@signatureVersion) || !Util.equalString(@signatureVersion, 'v4')) {
    return callApi(params, req, runtime);
  } else {
    return execute(params, req, runtime);
  }
}

/**
 * @summary 查询工作流目录列表
 *
 * @param request ListWorkflowDirectoriesRequest
 * @return ListWorkflowDirectoriesResponse
 */
async function listWorkflowDirectories(projectId: string, request: ListWorkflowDirectoriesRequest): ListWorkflowDirectoriesResponse {
  var runtime = new Util.RuntimeOptions{};
  var headers : map[string]string = {};
  return listWorkflowDirectoriesWithOptions(projectId, request, headers, runtime);
}

model ListWorkflowInstancesRequest {
  endTime?: string(name='endTime', example='2024-03-27 00:00:00'),
  maxResults?: int32(name='maxResults', example='10'),
  nextToken?: string(name='nextToken', example='123abc***'),
  startTime?: string(name='startTime', example='2024-03-27 00:00:00'),
  status?: string(name='status', example='SUCCESS'),
  workflowId?: string(name='workflowId', example='w-3q9jo749ne5****'),
  workspaceId?: string(name='workspaceId', description='This parameter is required.', example='12345'),
}

model ListWorkflowInstancesResponseBody = {
  data?: [ 
    {
      endTime?: string(name='endTime', example='2024-01-01 00:00:00'),
      name?: string(name='name', example='workflow_instance_name'),
      scheduleTime?: string(name='scheduleTime', example='2024-01-01 00:00:00'),
      startTime?: string(name='startTime', example='2024-01-01 00:00:00'),
      status?: string(name='status', example='SUCCESS'),
      workflowId?: string(name='workflowId', example='w-3q9jo749ne5****'),
      workflowInstanceId?: string(name='workflowInstanceId', example='wi-3q9jo749ne5****'),
      workflowVersion?: int32(name='workflowVersion', example='1'),
    }
  ](name='data'),
  nextToken?: string(name='nextToken', example='123abc***'),
  requestId?: string(name='requestId', example='DD6B1B2A-5837-5237-ABE4-FF0C8944****'),
  totalSize?: int32(name='totalSize', example='10'),
}

model ListWorkflowInstancesResponse = {
  headers?: map[string]string(name='headers'),
  statusCode?: int32(name='statusCode'),
  body?: ListWorkflowInstancesResponseBody(name='body'),
}

/**
 * @summary 获取工作流实例列表
 *
 * @param request ListWorkflowInstancesRequest
 * @param headers map
 * @param runtime runtime options for this request RuntimeOptions
 * @return ListWorkflowInstancesResponse
 */
async function listWorkflowInstancesWithOptions(projectId: string, request: ListWorkflowInstancesRequest, headers: map[string]string, runtime: Util.RuntimeOptions): ListWorkflowInstancesResponse {
  Util.validateModel(request);
  var query : map[string]any = {};
  if (!Util.isUnset(request.endTime)) {
    query['endTime'] = request.endTime;
  }
  if (!Util.isUnset(request.maxResults)) {
    query['maxResults'] = request.maxResults;
  }
  if (!Util.isUnset(request.nextToken)) {
    query['nextToken'] = request.nextToken;
  }
  if (!Util.isUnset(request.startTime)) {
    query['startTime'] = request.startTime;
  }
  if (!Util.isUnset(request.status)) {
    query['status'] = request.status;
  }
  if (!Util.isUnset(request.workflowId)) {
    query['workflowId'] = request.workflowId;
  }
  if (!Util.isUnset(request.workspaceId)) {
    query['workspaceId'] = request.workspaceId;
  }

  var req = new OpenApi.OpenApiRequest{ 
    headers = headers,
    query = OpenApiUtil.query(query),
  };
  var params = new OpenApi.Params{
    action = 'ListWorkflowInstances',
    version = '2024-04-30',
    protocol = 'HTTPS',
    pathname = `/dolphinscheduler/v3/projects/${OpenApiUtil.getEncodeParam(projectId)}/workflowInstances`,
    method = 'GET',
    authType = 'AK',
    style = 'ROA',
    reqBodyType = 'json',
    bodyType = 'json',
  };
  if (Util.isUnset(@signatureVersion) || !Util.equalString(@signatureVersion, 'v4')) {
    return callApi(params, req, runtime);
  } else {
    return execute(params, req, runtime);
  }
}

/**
 * @summary 获取工作流实例列表
 *
 * @param request ListWorkflowInstancesRequest
 * @return ListWorkflowInstancesResponse
 */
async function listWorkflowInstances(projectId: string, request: ListWorkflowInstancesRequest): ListWorkflowInstancesResponse {
  var runtime = new Util.RuntimeOptions{};
  var headers : map[string]string = {};
  return listWorkflowInstancesWithOptions(projectId, request, headers, runtime);
}

model ListWorkflowsRequest {
  maxResults?: int32(name='maxResults', example='20'),
  nextToken?: string(name='nextToken', example='123abc***'),
  searchVal?: string(name='searchVal', example='test'),
  workspaceId?: string(name='workspaceId', description='This parameter is required.', example='12345'),
}

model ListWorkflowsResponseBody = {
  data?: [ 
    {
      createTime?: string(name='createTime', example='2024-01-01 00:00:00'),
      description?: string(name='description', example='workflow description'),
      name?: string(name='name', example='workflow_name'),
      parentDirectoryId?: string(name='parentDirectoryId', example='wd-3q9jo749ne5****'),
      updateTime?: string(name='updateTime', example='2024-01-01 00:00:00'),
      workflowId?: string(name='workflowId', example='w-3q9jo749ne5****'),
    }
  ](name='data'),
  nextToken?: string(name='nextToken', example='123abc****'),
  requestId?: string(name='requestId', example='DD6B1B2A-5837-5237-ABE4-FF0C8944****'),
  totalSize?: int32(name='totalSize', example='10'),
}

model ListWorkflowsResponse = {
  headers?: map[string]string(name='headers'),
  statusCode?: int32(name='statusCode'),
  body?: ListWorkflowsResponseBody(name='body'),
}

/**
 * @summary 获取工作流列表
 *
 * @param request ListWorkflowsRequest
 * @param headers map
 * @param runtime runtime options for this request RuntimeOptions
 * @return ListWorkflowsResponse
 */
async function listWorkflowsWithOptions(projectId: string, request: ListWorkflowsRequest, headers: map[string]string, runtime: Util.RuntimeOptions): ListWorkflowsResponse {
  Util.validateModel(request);
  var query : map[string]any = {};
  if (!Util.isUnset(request.maxResults)) {
    query['maxResults'] = request.maxResults;
  }
  if (!Util.isUnset(request.nextToken)) {
    query['nextToken'] = request.nextToken;
  }
  if (!Util.isUnset(request.searchVal)) {
    query['searchVal'] = request.searchVal;
  }
  if (!Util.isUnset(request.workspaceId)) {
    query['workspaceId'] = request.workspaceId;
  }

  var req = new OpenApi.OpenApiRequest{ 
    headers = headers,
    query = OpenApiUtil.query(query),
  };
  var params = new OpenApi.Params{
    action = 'ListWorkflows',
    version = '2024-04-30',
    protocol = 'HTTPS',
    pathname = `/dolphinscheduler/v3/projects/${OpenApiUtil.getEncodeParam(projectId)}/workflows`,
    method = 'GET',
    authType = 'AK',
    style = 'ROA',
    reqBodyType = 'json',
    bodyType = 'json',
  };
  if (Util.isUnset(@signatureVersion) || !Util.equalString(@signatureVersion, 'v4')) {
    return callApi(params, req, runtime);
  } else {
    return execute(params, req, runtime);
  }
}

/**
 * @summary 获取工作流列表
 *
 * @param request ListWorkflowsRequest
 * @return ListWorkflowsResponse
 */
async function listWorkflows(projectId: string, request: ListWorkflowsRequest): ListWorkflowsResponse {
  var runtime = new Util.RuntimeOptions{};
  var headers : map[string]string = {};
  return listWorkflowsWithOptions(projectId, request, headers, runtime);
}

model OperateWorkflowInstanceRequest {
  execType?: string(name='execType', example='PAUSE'),
  workflowInstanceId?: string(name='workflowInstanceId', example='wi-l9o479p8rrx****'),
  workspaceId?: string(name='workspaceId', example='w-lxyy60mpgpg****'),
}

model OperateWorkflowInstanceResponseBody = {
  requestId?: string(name='requestId', description='Id of the request', example='DD6B1B2A-5837-5237-ABE4-FF0C8944****'),
  success?: boolean(name='success', example='true'),
}

model OperateWorkflowInstanceResponse = {
  headers?: map[string]string(name='headers'),
  statusCode?: int32(name='statusCode'),
  body?: OperateWorkflowInstanceResponseBody(name='body'),
}

/**
 * @summary 操作工作流实例
 *
 * @param request OperateWorkflowInstanceRequest
 * @param headers map
 * @param runtime runtime options for this request RuntimeOptions
 * @return OperateWorkflowInstanceResponse
 */
async function operateWorkflowInstanceWithOptions(projectId: string, request: OperateWorkflowInstanceRequest, headers: map[string]string, runtime: Util.RuntimeOptions): OperateWorkflowInstanceResponse {
  Util.validateModel(request);
  var query : map[string]any = {};
  if (!Util.isUnset(request.workspaceId)) {
    query['workspaceId'] = request.workspaceId;
  }

  var body : map[string]any = {};
  if (!Util.isUnset(request.execType)) {
    body['execType'] = request.execType;
  }
  if (!Util.isUnset(request.workflowInstanceId)) {
    body['workflowInstanceId'] = request.workflowInstanceId;
  }

  var req = new OpenApi.OpenApiRequest{ 
    headers = headers,
    query = OpenApiUtil.query(query),
    body = OpenApiUtil.parseToMap(body),
  };
  var params = new OpenApi.Params{
    action = 'OperateWorkflowInstance',
    version = '2024-04-30',
    protocol = 'HTTPS',
    pathname = `/dolphinscheduler/v3/projects/${OpenApiUtil.getEncodeParam(projectId)}/executors/execute`,
    method = 'POST',
    authType = 'AK',
    style = 'ROA',
    reqBodyType = 'json',
    bodyType = 'json',
  };
  if (Util.isUnset(@signatureVersion) || !Util.equalString(@signatureVersion, 'v4')) {
    return callApi(params, req, runtime);
  } else {
    return execute(params, req, runtime);
  }
}

/**
 * @summary 操作工作流实例
 *
 * @param request OperateWorkflowInstanceRequest
 * @return OperateWorkflowInstanceResponse
 */
async function operateWorkflowInstance(projectId: string, request: OperateWorkflowInstanceRequest): OperateWorkflowInstanceResponse {
  var runtime = new Util.RuntimeOptions{};
  var headers : map[string]string = {};
  return operateWorkflowInstanceWithOptions(projectId, request, headers, runtime);
}

model RunWorkflowRequest {
  alertGroupId?: string(name='alertGroupId', example='ag-n72kong0832****'),
  alertStrategy?: string(name='alertStrategy', example='NONE'),
  complementDependentMode?: string(name='complementDependentMode', example='OFF_MODE'),
  dryRun?: string(name='dryRun', example='0'),
  execType?: string(name='execType', example='START_PROCESS'),
  expectedParallelismNumber?: string(name='expectedParallelismNumber', example='1'),
  failureStrategy?: string(name='failureStrategy', example='END'),
  resourceGroupId?: string(name='resourceGroupId', description='This parameter is required.', example='wg-acfmv4opbs****'),
  runMode?: string(name='runMode', example='RUN_MODE_PARALLEL'),
  scheduleTime?: string(name='scheduleTime', example='2024-01-01 00:00:00,2024-01-02 00:00:00'),
  startParams?: string(name='startParams', example='{"key1":"value1"}'),
  workflowId?: string(name='workflowId', description='This parameter is required.', example='w-3q9jo749ne5****'),
  workflowInstancePriority?: string(name='workflowInstancePriority', example='MEDIUM'),
  workspaceId?: string(name='workspaceId', description='This parameter is required.', example='12345'),
}

model RunWorkflowResponseBody = {
  requestId?: string(name='requestId', description='Id of the request', example='DD6B1B2A-5837-5237-ABE4-FF0C8944****'),
  success?: boolean(name='success', example='true'),
}

model RunWorkflowResponse = {
  headers?: map[string]string(name='headers'),
  statusCode?: int32(name='statusCode'),
  body?: RunWorkflowResponseBody(name='body'),
}

/**
 * @summary 运行工作流
 *
 * @param request RunWorkflowRequest
 * @param headers map
 * @param runtime runtime options for this request RuntimeOptions
 * @return RunWorkflowResponse
 */
async function runWorkflowWithOptions(projectId: string, request: RunWorkflowRequest, headers: map[string]string, runtime: Util.RuntimeOptions): RunWorkflowResponse {
  Util.validateModel(request);
  var query : map[string]any = {};
  if (!Util.isUnset(request.alertGroupId)) {
    query['alertGroupId'] = request.alertGroupId;
  }
  if (!Util.isUnset(request.alertStrategy)) {
    query['alertStrategy'] = request.alertStrategy;
  }
  if (!Util.isUnset(request.complementDependentMode)) {
    query['complementDependentMode'] = request.complementDependentMode;
  }
  if (!Util.isUnset(request.dryRun)) {
    query['dryRun'] = request.dryRun;
  }
  if (!Util.isUnset(request.execType)) {
    query['execType'] = request.execType;
  }
  if (!Util.isUnset(request.expectedParallelismNumber)) {
    query['expectedParallelismNumber'] = request.expectedParallelismNumber;
  }
  if (!Util.isUnset(request.failureStrategy)) {
    query['failureStrategy'] = request.failureStrategy;
  }
  if (!Util.isUnset(request.resourceGroupId)) {
    query['resourceGroupId'] = request.resourceGroupId;
  }
  if (!Util.isUnset(request.runMode)) {
    query['runMode'] = request.runMode;
  }
  if (!Util.isUnset(request.scheduleTime)) {
    query['scheduleTime'] = request.scheduleTime;
  }
  if (!Util.isUnset(request.startParams)) {
    query['startParams'] = request.startParams;
  }
  if (!Util.isUnset(request.workflowId)) {
    query['workflowId'] = request.workflowId;
  }
  if (!Util.isUnset(request.workflowInstancePriority)) {
    query['workflowInstancePriority'] = request.workflowInstancePriority;
  }
  if (!Util.isUnset(request.workspaceId)) {
    query['workspaceId'] = request.workspaceId;
  }

  var req = new OpenApi.OpenApiRequest{ 
    headers = headers,
    query = OpenApiUtil.query(query),
  };
  var params = new OpenApi.Params{
    action = 'RunWorkflow',
    version = '2024-04-30',
    protocol = 'HTTPS',
    pathname = `/dolphinscheduler/v3/projects/${OpenApiUtil.getEncodeParam(projectId)}/executors/run-workflow`,
    method = 'POST',
    authType = 'AK',
    style = 'ROA',
    reqBodyType = 'json',
    bodyType = 'json',
  };
  if (Util.isUnset(@signatureVersion) || !Util.equalString(@signatureVersion, 'v4')) {
    return callApi(params, req, runtime);
  } else {
    return execute(params, req, runtime);
  }
}

/**
 * @summary 运行工作流
 *
 * @param request RunWorkflowRequest
 * @return RunWorkflowResponse
 */
async function runWorkflow(projectId: string, request: RunWorkflowRequest): RunWorkflowResponse {
  var runtime = new Util.RuntimeOptions{};
  var headers : map[string]string = {};
  return runWorkflowWithOptions(projectId, request, headers, runtime);
}

model UpdateWorkflowRequest {
  alertGroupId?: string(name='alertGroupId', example='ag-n72kong0832****'),
  alertStrategy?: string(name='alertStrategy', example='NONE'),
  taskDefinitionJsonValue?: string(name='taskDefinitionJsonValue'),
  taskRelationJsonValue?: string(name='taskRelationJsonValue'),
  cronExpr?: string(name='cronExpr', example='0 0 * * * ? *'),
  description?: string(name='description', example='test'),
  executionType?: string(name='executionType', example='PARALLEL'),
  failureStrategy?: string(name='failureStrategy', example='END'),
  name?: string(name='name', example='test'),
  parentDirectoryId?: string(name='parentDirectoryId', example='wd-n72kong0832****'),
  resourceGroupId?: string(name='resourceGroupId', example='wg-acfmv4opbs****'),
  scheduleEndTime?: string(name='scheduleEndTime', example='2024-01-01 00:00:00'),
  scheduleStartTime?: string(name='scheduleStartTime', example='2024-01-01 00:00:00'),
  scheduleState?: string(name='scheduleState', example='OFFLINE'),
  taskDefinitionJson?: string(name='taskDefinitionJson', example='[{"taskId":"t1","name":"t1","taskParams":{"rawScript":"echo 1"},"taskType":"SHELL"}]'),
  taskRelationJson?: string(name='taskRelationJson', example='[{"preTaskId":"0", "postTaskId":"t1"}]'),
  timeZone?: string(name='timeZone', example='Asia/Shanghai'),
  timeout?: int32(name='timeout', example='10'),
  workflowInstancePriority?: string(name='workflowInstancePriority', example='MEDIUM'),
  workflowParams?: string(name='workflowParams', example='[{"prop":"key1","value":"value1"}]'),
  workspaceId?: string(name='workspaceId', description='This parameter is required.', example='123***'),
}

model UpdateWorkflowResponseBody = {
  requestId?: string(name='requestId', description='Id of the request', example='DD6B1B2A-5837-5237-ABE4-FF0C8944****'),
  success?: boolean(name='success', example='true'),
}

model UpdateWorkflowResponse = {
  headers?: map[string]string(name='headers'),
  statusCode?: int32(name='statusCode'),
  body?: UpdateWorkflowResponseBody(name='body'),
}

/**
 * @summary 更新工作流
 *
 * @param request UpdateWorkflowRequest
 * @param headers map
 * @param runtime runtime options for this request RuntimeOptions
 * @return UpdateWorkflowResponse
 */
async function updateWorkflowWithOptions(projectId: string, workflowId: string, request: UpdateWorkflowRequest, headers: map[string]string, runtime: Util.RuntimeOptions): UpdateWorkflowResponse {
  Util.validateModel(request);
  var query : map[string]any = {};
  if (!Util.isUnset(request.alertGroupId)) {
    query['alertGroupId'] = request.alertGroupId;
  }
  if (!Util.isUnset(request.alertStrategy)) {
    query['alertStrategy'] = request.alertStrategy;
  }
  if (!Util.isUnset(request.cronExpr)) {
    query['cronExpr'] = request.cronExpr;
  }
  if (!Util.isUnset(request.description)) {
    query['description'] = request.description;
  }
  if (!Util.isUnset(request.executionType)) {
    query['executionType'] = request.executionType;
  }
  if (!Util.isUnset(request.failureStrategy)) {
    query['failureStrategy'] = request.failureStrategy;
  }
  if (!Util.isUnset(request.name)) {
    query['name'] = request.name;
  }
  if (!Util.isUnset(request.parentDirectoryId)) {
    query['parentDirectoryId'] = request.parentDirectoryId;
  }
  if (!Util.isUnset(request.resourceGroupId)) {
    query['resourceGroupId'] = request.resourceGroupId;
  }
  if (!Util.isUnset(request.scheduleEndTime)) {
    query['scheduleEndTime'] = request.scheduleEndTime;
  }
  if (!Util.isUnset(request.scheduleStartTime)) {
    query['scheduleStartTime'] = request.scheduleStartTime;
  }
  if (!Util.isUnset(request.scheduleState)) {
    query['scheduleState'] = request.scheduleState;
  }
  if (!Util.isUnset(request.taskDefinitionJson)) {
    query['taskDefinitionJson'] = request.taskDefinitionJson;
  }
  if (!Util.isUnset(request.taskRelationJson)) {
    query['taskRelationJson'] = request.taskRelationJson;
  }
  if (!Util.isUnset(request.timeZone)) {
    query['timeZone'] = request.timeZone;
  }
  if (!Util.isUnset(request.timeout)) {
    query['timeout'] = request.timeout;
  }
  if (!Util.isUnset(request.workflowInstancePriority)) {
    query['workflowInstancePriority'] = request.workflowInstancePriority;
  }
  if (!Util.isUnset(request.workflowParams)) {
    query['workflowParams'] = request.workflowParams;
  }
  if (!Util.isUnset(request.workspaceId)) {
    query['workspaceId'] = request.workspaceId;
  }

  var body : map[string]any = {};
  if (!Util.isUnset(request.taskDefinitionJsonValue)) {
    body['taskDefinitionJsonValue'] = request.taskDefinitionJsonValue;
  }
  if (!Util.isUnset(request.taskRelationJsonValue)) {
    body['taskRelationJsonValue'] = request.taskRelationJsonValue;
  }

  var req = new OpenApi.OpenApiRequest{ 
    headers = headers,
    query = OpenApiUtil.query(query),
    body = OpenApiUtil.parseToMap(body),
  };
  var params = new OpenApi.Params{
    action = 'UpdateWorkflow',
    version = '2024-04-30',
    protocol = 'HTTPS',
    pathname = `/dolphinscheduler/v3/projects/${OpenApiUtil.getEncodeParam(projectId)}/workflows/${OpenApiUtil.getEncodeParam(workflowId)}`,
    method = 'PUT',
    authType = 'AK',
    style = 'ROA',
    reqBodyType = 'json',
    bodyType = 'json',
  };
  if (Util.isUnset(@signatureVersion) || !Util.equalString(@signatureVersion, 'v4')) {
    return callApi(params, req, runtime);
  } else {
    return execute(params, req, runtime);
  }
}

/**
 * @summary 更新工作流
 *
 * @param request UpdateWorkflowRequest
 * @return UpdateWorkflowResponse
 */
async function updateWorkflow(projectId: string, workflowId: string, request: UpdateWorkflowRequest): UpdateWorkflowResponse {
  var runtime = new Util.RuntimeOptions{};
  var headers : map[string]string = {};
  return updateWorkflowWithOptions(projectId, workflowId, request, headers, runtime);
}

